package com.apes.framework.plugin.fsm;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.jpa.ApesBean;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.jpa.tuple.date.DateTime;
import com.apes.framework.plugin.outbox.annotation.OutBoxExclude;
import com.apes.framework.util.ApesConst;
import com.apes.framework.util.DateUtil;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenerationTime;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * 功能：定时任务日志
 *
 * @author xul
 * @create 2018-11-27 08:46
 */
@OutBoxExclude
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = FsmTaskLog.CONST_TABLE_NAME)
public class FsmTaskLog implements ApesBean {
    public static final String CONST_TABLE_NAME = "fsm_task_log";

    @Id
    @Column(name = "id", length = 60)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "状态任务执行日志")
    private String id;

    @Column(name = "task_id", length = 60, nullable = false)
    @Comment("任务Id")
    private String taskId;

    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(name = "description", columnDefinition = "CLOB")
    @Comment("描述")
    private String description;

    @JSONField(format = DateUtil.SHOW_DATETIME_FORMAT)
    @DateTime(GenerationTime.INSERT)
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "create_date", updatable = false)
    @Comment("创建时间")
    private Date createDate;

    @Column(name = "success", nullable = false, columnDefinition = ApesConst.FIELD_BOOLEAN_TRUE)
    @Comment("是否成功")
    private boolean success = true;


}
